﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.EquipmentManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.EquipmentManagement.EquipmentSpotRecordVMs
{
    public partial class EquipmentSpotRecordSpotTableDetailListVM : BasePagedListVM<EquipmentSpotRecord, EquipmentSpotRecordDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("EquipmentSpotRecord", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("EquipmentSpotRecord", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<EquipmentSpotRecord>> InitGridHeader()
        {
            return new List<GridColumn<EquipmentSpotRecord>>{
                
                this.MakeGridHeader(x => x.Content).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.点检内容"].Value),
                this.MakeGridHeader(x => x.SpotType).SetEditType(EditTypeEnum.ComboBox,typeof(SpotTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.点检类型"].Value),
                this.MakeGridHeader(x => x.Status).SetEditType(EditTypeEnum.ComboBox,typeof(SpotStatusEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.点检结果"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<EquipmentSpotRecord> GetSearchQuery()
        {
                
            var id = Searcher.SpotTableId;
            if (id == null)
                return new List<EquipmentSpotRecord>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<EquipmentSpotRecord>()
                .Where(x => id == x.SpotTableId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class EquipmentSpotRecordDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._EquipmentSpotRecord._SpotTable")]
        public long? SpotTableId { get; set; }
    }

}

